<?php
/* @package     Joomla.Site
 * @subpackage  mod_booking
 * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt*/
defined('_JEXEC') or die;
$type 		= $params->get('type',	1);
$catid 		= $params->get('catid',  '');
$lang = JRequest::getVar('lang','');
$Itemid = JRequest::getVar('Itemid','101');
$db = & JFactory::getDBO();
if($type==0){
?>
	<img class="topcountdown" src="images/headers/img_countdowntop.png" alt="Count Down Image" title="Count Down Image" />
    <script type="text/javascript">		
	var note="Octoberfest 2014 has arrived!";	
	var year=2014;
	var month=10;
	var day=10;
	var hour=00;
	var minute=00;
	var tz=-5;
	d1 = new Image(); d1.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/1.png";
	d2 = new Image(); d2.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/2.png";
	d3 = new Image(); d3.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/3.png";
	d4 = new Image(); d4.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/4.png";
	d5 = new Image(); d5.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/5.png";
	d6 = new Image(); d6.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/6.png";
	d7 = new Image(); d7.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/7.png";
	d8 = new Image(); d8.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/8.png";
	d9 = new Image(); d9.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/9.png";
	d0 = new Image(); d0.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/0.png";
	bkgd = new Image(); bkgd.src = "http://wmcvip.vn/WMCGroup/Oktoberfest2014/images/countdown/bkgd.gif";
	var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	function countdown(yr,m,d,hr,min){
		theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min;
		var today=new Date();
		var todayy=today.getYear();
		if (todayy < 1000) {todayy+=1900;}
		var todaym=today.getMonth();
		var todayd=today.getDate();
		var todayh=today.getHours();
		var todaymin=today.getMinutes();
		var todaysec=today.getSeconds();
		var todaystring1=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
		var todaystring=Date.parse(todaystring1)+(tz*1000*60*60);
		var futurestring1=(montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min);
		var futurestring=Date.parse(futurestring1)-(today.getTimezoneOffset()*(1000*60));
		var dd=futurestring-todaystring;
		var dday=Math.floor(dd/(60*60*1000*24)*1);
		var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
		var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
		var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
		if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){
			document.getElementById('note').innerHTML=note;
			document.getElementById('note').style.display="block";
			document.getElementById('countdown').style.display="none";
			clearTimeout(startTimer);
			return;
		}
		else {
			document.getElementById('note').style.display="none";
			document.getElementById('timer').style.display="block";
			startTimer = setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",500);
		}
		convert(dday,dhour,dmin,dsec);
	}
	function convert(d,h,m,s) {
		if (!document.images) return;
		if (d <= 9) {
			document.images.day1.src = bkgd.src;
			document.images.day2.src = bkgd.src;
			document.images.day3.src = eval("d"+d+".src");
		}
		else if (d <= 99) {
			document.images.day1.src = bkgd.src;
			document.images.day2.src = eval("d"+Math.floor(d/10)+".src");
			document.images.day3.src = eval("d"+(d%10)+".src");
		}
		else {
			document.images.day1.src = eval("d"+Math.floor(d/100)+".src");
			var day = d.toString();
			day = day.substr(1,1);
			day = parseInt(day);
			document.images.day2.src = eval("d"+day+".src");
			document.images.day3.src = eval("d"+(d%10)+".src");
		}
		if (h <= 9) {
			document.images.h1.src = d0.src;
			document.images.h2.src = eval("d"+h+".src");
		}
		else {
			document.images.h1.src = eval("d"+Math.floor(h/10)+".src");
			document.images.h2.src = eval("d"+(h%10)+".src");
		}
		if (m <= 9) {
			document.images.m1.src = d0.src;
			document.images.m2.src = eval("d"+m+".src");
		}
		else {document.images.m1.src = eval("d"+Math.floor(m/10)+".src");document.images.m2.src = eval("d"+(m%10)+".src");}
		if (s <= 9) {document.images.s1.src = d0.src;document.images.s2.src = eval("d"+s+".src");}
		else {document.images.s1.src = eval("d"+Math.floor(s/10)+".src");document.images.s2.src = eval("d"+(s%10)+".src");}
	}
	</script>
    <div id="timer">
        <div id="note"></div>
        <div id="countdown">
        	<div class="timeimg">
            <img src="images/countdown/bkgd.gif" name="day1">
            <img src="images/countdown/bkgd.gif" name="day2">
            <img src="images/countdown/bkgd.gif" name="day3">
            <img id="colon1" src="images/countdown/colon.png" name="d1">
            <img src="images/countdown/bkgd.gif" name="h1">
            <img src="images/countdown/bkgd.gif" name="h2">
            <img id="colon2" src="images/countdown/colon.png" name="g1">
            <img src="images/countdown/bkgd.gif" name="m1">
            <img src="images/countdown/bkgd.gif" name="m2">
            <img id="colon3" src="images/countdown/colon.png" name="j1">
            <img src="images/countdown/bkgd.gif" name="s1">
            <img src="images/countdown/bkgd.gif" name="s2">
            </div>
            <div id="title">
            	<div class="title"><?php echo JText::_('DAYS');?></div>
                <div class="title"><?php echo JText::_('HOURS');?></div>
                <div class="title"><?php echo JText::_('MINUTES');?></div>
                <div class="title"><?php echo JText::_('SECONDS');?></div>
            </div>
        </div>
    </div>
    <div class="countdownsponsor">
    	<a target="_blank" href="http://windsorplazahotel.com"><img src="images/countdown/logo_wph.png" alt="Windsor Plaza Hotel" title="Windsor Plaza Hotel"></a>
        <a target="_blank" href="http://oktoberfestvietnam.com"><img src="images/countdown/logo_oktoberfest.png" alt="OktoberfestVietNam" title="OktoberfestVietNam"></a>
        <a target="_blank" href="http://www.gba-vietnam.org"><img src="images/countdown/logo_gba.png" alt="GBA" title="GBA"></a>
    </div>
<?php
}
if($type==1){
	$sql="SELECT * from #__content where catid='9' and state=1";
	$db->setQuery($sql);
	$rows = $db->loadObjectList();
?>
<script type="text/javascript" src="templates/protostar/js/jquery.carouFredSel.js"></script>
<div class="ourporfolio">
    <div id="home-portfolio-list" class="clearfix">
        <div id="portfolio" class="portfolio-normal clearfix">
        <?php
        for($i=0;$i<count($rows);$i++){
            $item = $rows[$i];
			
			$linkitem = 'index.php?option=com_content&view=article&id='.$item->id.'&catid='.$item->catid.'&Itemid=120';
            $rowsimg	=	$item->images;
            $rowsimg	=	explode('","',$rowsimg);
            $rowsimg	=	explode('":"',$rowsimg[0]);
            $rowsimg	=	str_replace('\/','/',$rowsimg[1]);
        ?>
            <div class="portfolio-item">
                <div class="portfolio-image">
                    <a href="<?php echo $linkitem; ?>"><img src="<?php echo $rowsimg; ?>" /><div class="item-overlay overlay-icon-pic"><span></span></div></a>
                </div>
                <div class="portfolio-desc">
                	<h3><a href="<?php echo $linkitem; ?>"><?php echo $item->title; ?></a></h3>
                    <div class="merchandisedes"><?php echo $item->introtext; ?></div>
                </div>
            </div>
        <?php
        }
        ?>
        </div>
        <div class="portfolio-navigation">
            <a href="#" id="home-portfolio-prev" class="portfolio-prev">Previous</a> 
            <a href="#" id="home-portfolio-next" class="portfolio-next">Next</a>
        </div>
        <div id="home-portfolio-pagination"></div>
        <script type="text/javascript">
        $("#portfolio").carouFredSel({
            circular:false,
            responsive:true,auto:false,
            items:{width:200,visible:{min:1,max:5}},
            scroll:{duration:900,easing:"easeOutExpo",wipe:true},
            prev:{button:"#home-portfolio-prev",key:"left"},
            next:{button:"#home-portfolio-next",key:"right"},
            pagination:"#home-portfolio-pagination"});
        </script>
    </div>
</div>
<?php
}
if($type==2){
	$querytabs = "SELECT * FROM #__content WHERE catid=2 and state=1 order by ordering asc";
	$db->setQuery($querytabs);
	$tabscount = $db->loadObjectList();
?>
<script type="text/javascript" src="templates/protostar/js/jquery-ui.js"></script>
<script type="text/javascript">
	jQuery(function(){
		var tabCounter = 2;
		var tabs = jQuery("#tabs").tabs();
		tabs.bind( "keyup", function( event ){
			if ( event.altKey && event.keyCode === jQuery.ui.keyCode.BACKSPACE ){
				var panelId = tabs.find( ".ui-tabs-active" ).remove().attr( "aria-controls" );jQuery( "#" + panelId ).remove();tabs.tabs( "refresh" );}});});
</script>
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all pagenewslist" id="tabs">
	<ul role="tablist" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
		<?php 
		for($i=0;$i<count($tabscount);$i++){
		?>
        <li aria-selected="true" aria-controls="tabs-<?php echo $i;?>" class="ui-state-default ui-corner-top">
            <div class="page_header catroom">
                <h2><strong><a id="ui-id-<?php echo $i;?>" class="ui-tabs-anchor" href="#tabs-<?php echo $i;?>"><?php echo $tabscount[$i]->title; ?></a></strong></h2>
            </div>
        </li>
        <?php
		}
		?>
	</ul>
    <?php 
	for($i=0;$i<count($tabscount);$i++){
	?>
	<div class="ui-tabs-panel" id="tabs-<?php echo $i;?>">
    	<h2><?php echo $tabscount[$i]->title;?></h2>
        <div class="contentfestival"><?php echo $tabscount[$i]->introtext;?></div>
    </div>
	<?php
    }
    ?>
</div>
<?php
}
if($type==3){
	$querytabs = "SELECT * FROM #__content WHERE catid=8 and state=1 order by ordering asc";
	$db->setQuery($querytabs);
	$tabscount = $db->loadObjectList();
	for($i=0;$i<count($tabscount);$i++){
		$imgbutton = $tabscount[$i]->images;
		$imgbutton = explode('"image_intro":"',$imgbutton);
		$imgbutton = explode('","',$imgbutton[1]);
		$imgbutton = str_replace('\/','/',$imgbutton[0]);
		$idname = $tabscount[$i]->metadata;
		$idname = explode('"xreference":"',$idname);
		$idname = explode('"',$idname[1]);
		$idname = $idname[0];
		
		$imgdisplay = "";
		$link="";
		if($imgbutton!=""){$imgdisplay = '<a class="btnbeerfood" href=""><img src="'.$imgbutton.'"></a>';}
	?>
        <div id="<?php echo $idname;?>" class="pagebeersfood">
            <div class="contentpagebeerfood">
            	<div class="page-header"><h2><?php echo $tabscount[$i]->title;?></h2></div>
            	<?php echo $tabscount[$i]->introtext;?>
            </div>
            <?php echo $imgdisplay;?>
        </div>
    <?php
	}
}
if($type==4){
?>
Entertainment
<?php
}
if($type==5){
?>Media
<?php
}
if($type==6){
?>Gallery
<?php
}
if($type==7){
	$document = &JFactory::getDocument();
	$renderer   = $document->loadRenderer('modules');
	$position   = 'sponsorcontent';
	$options   = array('style' => 'wellla');
	echo $renderer->render($position, $options, null);
?>Sponsor
<?php
}
if($type==8){
?>
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d1959.8503388571394!2d106.673845!3d10.7575361!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x31752efd2e90475f%3A0xd84d58102f2e8b6b!2zMTggQW4gRMawxqFuZyBWxrDGoW5nLCAxNiwgUXXhuq1uIDUsIEjhu5MgQ2jDrSBNaW5oLCBWaWV0bmFt!5e0!3m2!1sen!2s!4v1405484172577" width="865" height="380" frameborder="0" style="border:0"></iframe>
<?php
	$document = &JFactory::getDocument();
	$renderer   = $document->loadRenderer('modules');
	$position   = 'contactcontent';
	$options   = array('style' => 'raw');
	echo $renderer->render($position, $options, null);
}
if($type==9){
?>aaaaaaaaaaaaa
<?php
}
?>
